<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta charset="UTF-8">
    <title>知识库后台管理：栏目发布</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
    <!-- bootstrap & fontawesome -->
    <link rel="stylesheet" href="../css/bootstrap.css"/>
    <link rel="stylesheet" href="../css/font-awesome.css"/>

    <!-- page specific plugin styles -->
    <link rel="stylesheet" href="css/jquery-ui.min.css"/>
    <link rel="stylesheet" href="css/jqGrid/ui.jqgrid.css"/>
    <link rel="stylesheet" href="css/admin.css"/>

   <!-- text fonts -->
    <link rel="stylesheet" href="css/ace-fonts.css"/>
    <!-- ace styles -->
    <link rel="stylesheet" href="css/ace.min.css" id="main-ace-style"/>


    <!--[if lte IE 9]>
    <link rel="stylesheet" href="css/ace-part2.min.css"/>
    <![endif]-->
    <link rel="stylesheet" href="css/ace-skins.min.css"/>
    <link rel="stylesheet" href="css/ace-rtl.min.css"/>

    <!--[if lte IE 9]>
    <link rel="stylesheet" href="css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->
    <script src="js/ace-extra.min.js"></script>

    <!-- HTML5shiv and Respond.js for IE8 to support HTML5 elements and media queries -->

    <!--[if lte IE 8]>
    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>
    <![endif]-->

</head>
<body class="no-skin">
<!-- #section:basics/navbar.layout -->
<div id="navbar" class="navbar navbar-default">
    <script type="text/javascript">
        try {
            ace.settings.check('navbar', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="navbar-container" id="navbar-container">
        <!-- #section:basics/sidebar.mobile.toggle -->
        <button type="button" class="navbar-toggle menu-toggler pull-left" id="menu-toggler">
            <span class="sr-only">Toggle sidebar</span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>

            <span class="icon-bar"></span>
        </button>

        <!-- /section:basics/sidebar.mobile.toggle -->
        <div class="navbar-header pull-left">
            <!-- #section:basics/navbar.layout.brand -->
            <a href="#" class="navbar-brand">
                <small>
                    <i class="fa fa-leaf"></i>
                    知识库后台管理
                </small>
            </a>

            <!-- /section:basics/navbar.layout.brand -->

            <!-- #section:basics/navbar.toggle -->

            <!-- /section:basics/navbar.toggle -->
        </div>

        <!-- #section:basics/navbar.dropdown -->
        <div class="navbar-buttons navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
                <!-- #section:basics/navbar.user_menu -->
                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="images/user.jpg" alt="Jason's Photo"/>
								<span class="user-info">
									<small>Welcome,</small>
									Jason
								</span>

                        <i class="ace-icon fa fa-caret-down"></i>
                    </a>

                    <ul class="user-menu dropdown-menu-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="#">
                                <i class="ace-icon fa fa-cog"></i>
                                Settings
                            </a>
                        </li>

                        <li>
                            <a href="profile.html">
                                <i class="ace-icon fa fa-user"></i>
                                Profile
                            </a>
                        </li>

                        <li class="divider"></li>

                        <li>
                            <a href="#">
                                <i class="ace-icon fa fa-power-off"></i>
                                Logout
                            </a>
                        </li>
                    </ul>
                </li>

                <!-- /section:basics/navbar.user_menu -->
            </ul>
        </div>

        <!-- /section:basics/navbar.dropdown -->
    </div><!-- /.navbar-container -->
</div>

<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <!-- #section:basics/sidebar -->
    <div id="sidebar" class="sidebar responsive">
        <script type="text/javascript">
            try {
                ace.settings.check('sidebar', 'fixed')
            } catch (e) {
            }
        </script>

        <div class="sidebar-shortcuts" id="sidebar-shortcuts">
            <div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
                <button class="btn btn-success">
                    <i class="ace-icon fa fa-signal"></i>
                </button>

                <button class="btn btn-info">
                    <i class="ace-icon fa fa-pencil"></i>
                </button>

                <!-- #section:basics/sidebar.layout.shortcuts -->
                <button class="btn btn-warning">
                    <i class="ace-icon fa fa-users"></i>
                </button>

                <button class="btn btn-danger">
                    <i class="ace-icon fa fa-cogs"></i>
                </button>

                <!-- /section:basics/sidebar.layout.shortcuts -->
            </div>

            <div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
                <span class="btn btn-success"></span>

                <span class="btn btn-info"></span>

                <span class="btn btn-warning"></span>

                <span class="btn btn-danger"></span>
            </div>
        </div><!-- /.sidebar-shortcuts -->

        <ul class="nav nav-list">
            <li>
                <a href="index.html">
                    <i class="menu-icon fa fa-tachometer"></i>
                    <span class="menu-text"> 控制台 </span>
                </a>

                <b class="arrow"></b>
            </li>

            <li class="">
                <a href="#" class="dropdown-toggle">
                    <i class="menu-icon fa fa-desktop"></i>
                    <span class="menu-text"> 用户管理</span>

                    <b class="arrow fa fa-angle-down"></b>
                </a>

                <b class="arrow"></b>

                <ul class="submenu">
                    <li class="">
                        <a href="#">
                            <i class="menu-icon fa fa-caret-right"></i>
                            账号管理
                        </a>

                        <b class="arrow"></b>
                    </li>

                    <li class="">
                        <a href="#">
                            <i class="menu-icon fa fa-caret-right"></i>
                            角色管理
                        </a>

                        <b class="arrow"></b>
                    </li>

                    <li class="">
                        <a href="#">
                            <i class="menu-icon fa fa-caret-right"></i>
                            权限管理
                        </a>

                        <b class="arrow"></b>
                    </li>
                </ul>
            </li>

            <li class="">
                <a href="#" class="dropdown-toggle">
                    <i class="menu-icon fa fa-list"></i>
                    <span class="menu-text"> 系统设置 </span>

                    <b class="arrow fa fa-angle-down"></b>
                </a>

                <b class="arrow"></b>

                <ul class="submenu">
                    <li>
                        <a href="menu.html">
                            <i class="menu-icon fa fa-caret-right"></i>
                            导航菜单
                        </a>
                        <b class="arrow"></b>
                    </li>
                    <li>
                        <a href="zskMenu.html">
                            <i class="menu-icon fa fa-caret-right"></i>
                            知识库菜单
                        </a>
                        <b class="arrow"></b>
                    </li>
                    <li>
                        <a href="carousel.html">
                            <i class="menu-icon fa fa-caret-right"></i>
                            轮播图片
                        </a>
                        <b class="arrow"></b>
                    </li>
                    <li>
                        <a href="terminal.html">
                            <i class="menu-icon fa fa-caret-right"></i>
                            终端图片
                        </a>
                        <b class="arrow"></b>
                    </li>
                </ul>
            </li>
            <li class="">
                <a href="#" class="dropdown-toggle">
                    <i class="menu-icon fa fa-pencil-square-o"></i>
                    <span class="menu-text"> 内容发布 </span>

                    <b class="arrow fa fa-angle-down"></b>
                </a>
                <b class="arrow"></b>
                <ul class="submenu">
                    <li class="active">
                        <a href="#">
                            <i class="menu-icon fa fa-caret-right"></i>
                            栏目内容
                        </a>
                        <b class="arrow"></b>
                    </li>
                    <li >
                        <a href="article.html">
                            <i class="menu-icon fa fa-caret-right"></i>
                            文章内容
                        </a>
                        <b class="arrow"></b>
                    </li>
                </ul>
            </li>


        </ul><!-- /.nav-list -->

        <!-- #section:basics/sidebar.layout.minimize -->
        <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
            <i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left"
               data-icon2="ace-icon fa fa-angle-double-right"></i>
        </div>

        <!-- /section:basics/sidebar.layout.minimize -->
        <script type="text/javascript">
            try {
                ace.settings.check('sidebar', 'collapsed')
            } catch (e) {
            }
        </script>
    </div>

    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <!-- #section:basics/content.breadcrumbs -->
        <div class="breadcrumbs" id="breadcrumbs">
            <script type="text/javascript">
                try {
                    ace.settings.check('breadcrumbs', 'fixed')
                } catch (e) {
                }
            </script>

            <ul class="breadcrumb">
                <li>
                    <i class="ace-icon fa fa-home home-icon"></i>
                    <a href="#">Home</a>
                </li>
                <li class="active">控制台</li>
            </ul><!-- /.breadcrumb -->

            <!-- #section:basics/content.searchbox -->
            <div class="nav-search" id="nav-search">
                <form class="form-search">
							<span class="input-icon">
								<input type="text" placeholder="Search ..." class="nav-search-input"
                                       id="nav-search-input" autocomplete="off"/>
								<i class="ace-icon fa fa-search nav-search-icon"></i>
							</span>
                </form>
            </div><!-- /.nav-search -->

            <!-- /section:basics/content.searchbox -->
        </div>

        <!-- /section:basics/content.breadcrumbs -->
        <div class="page-content">
            <!-- #section:settings.box -->
            <div class="ace-settings-container" id="ace-settings-container">
                <div class="btn btn-app btn-xs btn-warning ace-settings-btn" id="ace-settings-btn">
                    <i class="ace-icon fa fa-cog bigger-150"></i>
                </div>

                <div class="ace-settings-box clearfix" id="ace-settings-box">
                    <div class="pull-left width-50">
                        <!-- #section:settings.skins -->
                        <div class="ace-settings-item">
                            <div class="pull-left">
                                <select id="skin-colorpicker" class="hide">
                                    <option data-skin="no-skin" value="#438EB9">#438EB9</option>
                                    <option data-skin="skin-1" value="#222A2D">#222A2D</option>
                                    <option data-skin="skin-2" value="#C6487E">#C6487E</option>
                                    <option data-skin="skin-3" value="#D0D0D0">#D0D0D0</option>
                                </select>
                            </div>
                            <span>&nbsp; Choose Skin</span>
                        </div>

                        <!-- /section:settings.skins -->

                        <!-- #section:settings.navbar -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-navbar"/>
                            <label class="lbl" for="ace-settings-navbar"> Fixed Navbar</label>
                        </div>

                        <!-- /section:settings.navbar -->

                        <!-- #section:settings.sidebar -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-sidebar"/>
                            <label class="lbl" for="ace-settings-sidebar"> Fixed Sidebar</label>
                        </div>

                        <!-- /section:settings.sidebar -->

                        <!-- #section:settings.breadcrumbs -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-breadcrumbs"/>
                            <label class="lbl" for="ace-settings-breadcrumbs"> Fixed Breadcrumbs</label>
                        </div>

                        <!-- /section:settings.breadcrumbs -->

                        <!-- #section:settings.rtl -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-rtl"/>
                            <label class="lbl" for="ace-settings-rtl"> Right To Left (rtl)</label>
                        </div>

                        <!-- /section:settings.rtl -->

                        <!-- #section:settings.container -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-add-container"/>
                            <label class="lbl" for="ace-settings-add-container">
                                Inside
                                <b>.container</b>
                            </label>
                        </div>

                        <!-- /section:settings.container -->
                    </div><!-- /.pull-left -->

                    <div class="pull-left width-50">
                        <!-- #section:basics/sidebar.options -->
                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-hover"/>
                            <label class="lbl" for="ace-settings-hover"> Submenu on Hover</label>
                        </div>

                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-compact"/>
                            <label class="lbl" for="ace-settings-compact"> Compact Sidebar</label>
                        </div>

                        <div class="ace-settings-item">
                            <input type="checkbox" class="ace ace-checkbox-2" id="ace-settings-highlight"/>
                            <label class="lbl" for="ace-settings-highlight"> Alt. Active Item</label>
                        </div>

                        <!-- /section:basics/sidebar.options -->
                    </div><!-- /.pull-left -->
                </div><!-- /.ace-settings-box -->
            </div><!-- /.ace-settings-container -->

            <!-- /section:settings.box -->
            <div>
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->

                        <table id="grid-table"></table>
                        <div id="grid-pager"></div>

                        <div id="consoleDlg">
                            <div id="formContainer">
                                <form id="form1">
                                    <input type="hidden" id="selectId"/>
                                    <input type="hidden" id="taxonomyId"/>
                                    <input type="hidden" id="statusName"/>
                                    <table>
                                        <tr>
                                            <th>栏目标题（*）:</th>
                                            <td>
                                                <input type="text" id="title" name="title" />
                                            </td>
                                            <th>栏目简介（*）:</th>
                                            <td>
                                                <textarea id="summary" name="summary" rows="3" name="summary"></textarea>
                                            </td>
                                        </tr>
                                        <tr>
                                            <th>栏目（*）:</th>
                                            <td colspan="3">
                                                <select id="taxonomyId_1" name="taxonomyId_1" style="width: 100px;margin:10px 20px 10px 0px;">
                                                    <option selected="selected" value="-1">请选择</option>
                                                </select>
                                                <select id="taxonomyId_2" name="taxonomyId_2" style="width: 100px;margin:10px 20px 10px 0px;">
                                                    <option selected="selected" value="-1">请选择</option>
                                                </select>
                                                <select id="taxonomyId_3" name="taxonomyId_3" style="width: 100px;margin:10px 20px 10px 0px;">
                                                    <option selected="selected" value="-1">请选择</option>
                                                </select>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="4">
                                                <!-- 加载富文本编辑器的容器 -->
                                                <script id="editor" name="text" type="text/plain" style="width:860px;height:230px">
                                                </script>
                                            </td>
                                        </tr>
                                    </table>
                                </form>
                            </div>
                        </div>
                        <div id="viewDlg" >
                            <div id="content">
                                <div align="center">
                                    <h1><span id="pgTitle"></span></h1><br>
                                    &nbsp;&nbsp;<span id="pgAddTime" class="text-muted"></span>&nbsp;&nbsp;<span id="pgViewCount" class="text-muted"></span>
                                </div>
                                <div  id="pgSummary">
                                </div>
                                <div id="pgText">
                                </div>
                            </div>
                        </div>
                        <!-- PAGE CONTENT ENDS -->

                    </div><!-- /.col -->
                </div><!-- /.row -->
            </div><!-- /.page-content-area -->
        </div><!-- /.page-content -->
    </div><!-- /.main-content -->

    <div class="footer">
        <div class="footer-inner">
            <!-- #section:basics/footer -->
            <div class="footer-content">
						<span class="bigger-120">
							<span class="blue bolder">Ace</span>
							Application &copy; 2013-2014
						</span>

                &nbsp; &nbsp;
						<span class="action-buttons">
							<a href="#">
                                <i class="ace-icon fa fa-twitter-square light-blue bigger-150"></i>
                            </a>

							<a href="#">
                                <i class="ace-icon fa fa-facebook-square text-primary bigger-150"></i>
                            </a>

							<a href="#">
                                <i class="ace-icon fa fa-rss-square orange bigger-150"></i>
                            </a>
						</span>
            </div>

            <!-- /section:basics/footer -->
        </div>
    </div>

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->

<!-- basic scripts -->

<!--[if !IE]> -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='../js/jquery.min.js'>" + "<" + "/script>");
</script>

<!-- <![endif]-->

<!--[if IE]>
<script type="text/javascript">
    window.jQuery || document.write("<script src='../js/jquery1x.min.js'>" + "<" + "/script>");
</script>
<![endif]-->
<script type="text/javascript">
    if ('ontouchstart' in document.documentElement) document.write("<script src='../js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="../js/bootstrap.min.js"></script>


<!-- page specific plugin scripts -->
<script src="js/jqGrid/jquery.jqGrid.src.js"></script>
<script src="js/jqGrid/grid.locale-cn.js"></script>
<script src="js/jquery-ui.min.js"></script>
<script src="js/ajaxfileupload.js" type="text/javascript"></script>
<!-- utility scripts -->
<script src="js/util.js" type="text/javascript"></script>
<!-- 配置文件 -->
<script type="text/javascript" src="ueditor/ueditor.config.js"></script>
<!-- 编辑器源码文件 -->
<script type="text/javascript" src="ueditor/ueditor.all.js"></script>
<!-- 编辑器语言文件 -->
<script type="text/javascript" charset="utf-8" src="ueditor/lang/zh-cn/zh-cn.js"></script>

<!-- ace scripts -->
<script src="js/ace-elements.min.js"></script>
<script src="js/ace.min.js"></script>
<!-- inline scripts related to this page -->
<script type="text/javascript">

    function dateFormat( cellvalue, options, rowObject ){
        return new Date(cellvalue).Format("yyyy-MM-dd hh:mm:ss");
    }

    var grid_selector = "#grid-table";
    var pager_selector = "#grid-pager";
    jQuery(function ($) {
        //resize to fit page size
        $(window).on('resize.jqGrid', function () {
            $(grid_selector).jqGrid('setGridWidth', $(".page-content").width());
        })
        //resize on sidebar collapse/expand
        var parent_column = $(grid_selector).closest('[class*="col-"]');
        $(document).on('settings.ace.jqGrid', function (ev, event_name, collapsed) {
            if (event_name === 'sidebar_collapsed' || event_name === 'main_container_fixed') {
                //setTimeout is for webkit only to give time for DOM changes and then redraw!!!
                setTimeout(function () {
                    $(grid_selector).jqGrid('setGridWidth', parent_column.width());
                }, 0);
            }
        })
        jQuery(grid_selector).jqGrid({
            mtype: 'get',
            prmNames:{rows:'size'},
            ajaxGridOptions: {contentType: 'application/json;charset=utf-8'},
            datatype: "json",
            url: "/api/admin/content/lists?cid=0&insub=true&typeName=Page&time=" + new Date().getTime(),
            height: 330,
            colNames: [ 'ID', '栏目标题', '简介', '发布人','发布时间'],
            colModel: [
                {name: 'id', index: 'id', width: 20, sorttype: "int"},
                {name: 'title', index: 'title', width: 90, editable: true,editrules:{required:true}},
                {name: 'summary', index: 'summary', width: 150, editable: true, edittype:'textarea',editrules:{required:true}},
                {name: 'userName', index: 'userName', width: 50},
                {name: 'addTime',formatter:dateFormat, index: 'addTime', width: 60}
            ],
            viewrecords: true,
            sortname: 'addTime',    //按添加时间排序
            sortorder: 'desc',//降序
            rowNum: 10,
            rowList: [10, 20, 30],
            pager: pager_selector,
            altRows: true,
            //toppager: true,

            beforeProcessing: function () {

            },
            loadComplete: function () {
                var table = this;
                setTimeout(function () {
                    styleCheckbox(table);
                    updateActionIcons(table);
                    updatePagerIcons(table);
                    enableTooltips(table);
                }, 0);
            },
            loadError:function(xhr,status,error) {
                alert("加载数据失败！\n"+"error:" + error);
            },
            //editurl: "/api/admin/content/detail",
            caption: "栏目列表",
            jsonReader:{
                root:"data.items",
                page: "data.currentPage",
                total: "data.totalPage",
                records: "data.records",
                repeatitems: false,
                id: "id"
            },
        });

        $(window).triggerHandler('resize.jqGrid');//trigger window resize to make the grid get the correct size

        //switch element when editing inline
        function aceSwitch(cellvalue, options, cell) {
            setTimeout(function () {
                $(cell).find('input[type=checkbox]')
                        .addClass('ace ace-switch ace-switch-5')
                        .after('<span class="lbl"></span>');
            }, 0);
        }

        //navButtons
        jQuery(grid_selector).jqGrid('navGrid', pager_selector,
                { 	//navbar options
                    edit: true,
                    editicon: 'ace-icon fa fa-pencil blue',
                    add: true,
                    addicon: 'ace-icon fa fa-plus-circle purple',
                    del: true,
                    delicon: 'ace-icon fa fa-trash-o red',
                    search: false,
                    searchicon: 'ace-icon fa fa-search orange',
                    refresh: false,
                    refreshicon: 'ace-icon fa fa-refresh green',
                    view: true,
                    viewicon: 'ace-icon fa fa-search-plus grey',
                    addfunc : openDialog4Adding,
                    editfunc : openDialog4Updating,
                    viewfunc:viewRecord,
                    delfunc:deleteRecord
                },
                {
                    //edit record form
                    closeAfterEdit: true,
                    ajaxEditOptions: { contentType: "application/json" },
                    serializeEditData: function(postdata) {
                        return JSON.stringify(postdata);
                    },
                    //width: 700,
                    recreateForm: true,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                        style_edit_form(form);
                    }
                },
                {
                    //new record form
                    //width: 700,
                    closeAfterAdd: true,
                    ajaxEditOptions: { contentType: "application/json" },
                    serializeEditData: function(postdata) {
                        postdata.id = '';
                        return JSON.stringify(postdata);
                    },
                    recreateForm: true,
                    viewPagerButtons: false,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar')
                                .wrapInner('<div class="widget-header" />')
                        style_edit_form(form);
                    }
                },
                {
                    //delete record form
                    recreateForm: true,
                    ajaxDelOptions: { contentType: "application/json" },
                    serializeDelData: function(postdata) {
                        return JSON.stringify(postdata);
                    },
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        if (form.data('styled')) return false;

                        form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
                        style_delete_form(form);

                        form.data('styled', true);
                    },
                    onClick: function (e) {
                        alert(1);
                    }
                },
                {
                    //search form
                    recreateForm: true,
                    afterShowSearch: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
                        style_search_form(form);
                    },
                    afterRedraw: function () {
                        style_search_filters($(this));
                    }
                    ,
                    multipleSearch: true,
                    /**
                     multipleGroup:true,
                     showQuery: true
                     */
                },
                {
                    //view record form
                    recreateForm: true,
                    beforeShowForm: function (e) {
                        var form = $(e[0]);
                        form.closest('.ui-jqdialog').find('.ui-jqdialog-title').wrap('<div class="widget-header" />')
                    }
                }
        )



            function style_edit_form(form) {

            //don't wrap inside a label element, the checkbox value won't be submitted (POST'ed)
            //.addClass('ace ace-switch ace-switch-5').wrap('<label class="inline" />').after('<span class="lbl"></span>');

            //update buttons classes
            var buttons = form.next().find('.EditButton .fm-button');
            buttons.addClass('btn btn-sm').find('[class*="-icon"]').hide();//ui-icon, s-icon
            buttons.eq(0).addClass('btn-primary').prepend('<i class="ace-icon fa fa-check"></i>');
            buttons.eq(1).prepend('<i class="ace-icon fa fa-times"></i>')

            buttons = form.next().find('.navButton a');
            buttons.find('.ui-icon').hide();
            buttons.eq(0).append('<i class="ace-icon fa fa-chevron-left"></i>');
            buttons.eq(1).append('<i class="ace-icon fa fa-chevron-right"></i>');
        }

        function style_delete_form(form) {
            var buttons = form.next().find('.EditButton .fm-button');
            buttons.addClass('btn btn-sm btn-white btn-round').find('[class*="-icon"]').hide();//ui-icon, s-icon
            buttons.eq(0).addClass('btn-danger').prepend('<i class="ace-icon fa fa-trash-o"></i>');
            buttons.eq(1).addClass('btn-default').prepend('<i class="ace-icon fa fa-times"></i>')
        }

        function style_search_filters(form) {
            form.find('.delete-rule').val('X');
            form.find('.add-rule').addClass('btn btn-xs btn-primary');
            form.find('.add-group').addClass('btn btn-xs btn-success');
            form.find('.delete-group').addClass('btn btn-xs btn-danger');
        }

        function style_search_form(form) {
            var dialog = form.closest('.ui-jqdialog');
            var buttons = dialog.find('.EditTable')
            buttons.find('.EditButton a[id*="_reset"]').addClass('btn btn-sm btn-info').find('.ui-icon').attr('class', 'ace-icon fa fa-retweet');
            buttons.find('.EditButton a[id*="_query"]').addClass('btn btn-sm btn-inverse').find('.ui-icon').attr('class', 'ace-icon fa fa-comment-o');
            buttons.find('.EditButton a[id*="_search"]').addClass('btn btn-sm btn-purple').find('.ui-icon').attr('class', 'ace-icon fa fa-search');
        }

        function beforeDeleteCallback(e) {
            var form = $(e[0]);
            if (form.data('styled')) return false;
            form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
            style_delete_form(form);
            form.data('styled', true);
        }

        function beforeEditCallback(e) {
            var form = $(e[0]);
            form.closest('.ui-jqdialog').find('.ui-jqdialog-titlebar').wrapInner('<div class="widget-header" />')
            style_edit_form(form);
        }


        //it causes some flicker when reloading or navigating grid
        //it may be possible to have some custom formatter to do this as the grid is being created to prevent this
        //or go back to default browser checkbox styles for the grid
        function styleCheckbox(table) {
            /**
             $(table).find('input:checkbox').addClass('ace')
             .wrap('<label />')
             .after('<span class="lbl align-top" />')


             $('.ui-jqgrid-labels th[id*="_cb"]:first-child')
             .find('input.cbox[type=checkbox]').addClass('ace')
             .wrap('<label />').after('<span class="lbl align-top" />');
             */
        }


        //unlike navButtons icons, action icons in rows seem to be hard-coded
        //you can change them like this in here if you want
        function updateActionIcons(table) {

            /* var replacement =
             {
             'ui-ace-icon fa fa-pencil' : 'ace-icon fa fa-pencil blue',
             'ui-ace-icon fa fa-trash-o' : 'ace-icon fa fa-trash-o red',
             'ui-icon-disk' : 'ace-icon fa fa-check green',
             'ui-icon-cancel' : 'ace-icon fa fa-times red'
             };
             $(table).find('.ui-pg-div span.ui-icon').each(function(){
             var icon = $(this);
             var $class = $.trim(icon.attr('class').replace('ui-icon', ''));
             if($class in replacement) icon.attr('class', 'ui-icon '+replacement[$class]);
             })*/
        }

        //replace icons with FontAwesome icons like above
        function updatePagerIcons(table) {
            var replacement =
            {
                'ui-icon-seek-first': 'ace-icon fa fa-angle-double-left bigger-140',
                'ui-icon-seek-prev': 'ace-icon fa fa-angle-left bigger-140',
                'ui-icon-seek-next': 'ace-icon fa fa-angle-right bigger-140',
                'ui-icon-seek-end': 'ace-icon fa fa-angle-double-right bigger-140'
            };
            $('.ui-pg-table:not(.navtable) > tbody > tr > .ui-pg-button > .ui-icon').each(function () {
                var icon = $(this);
                var $class = $.trim(icon.attr('class').replace('ui-icon', ''));

                if ($class in replacement) icon.attr('class', 'ui-icon ' + replacement[$class]);
            })
        }

        function enableTooltips(table) {
            $('.navtable .ui-pg-button').tooltip({container: 'body'});
            $(table).find('.ui-pg-div').tooltip({container: 'body'});
        }

        //var selr = jQuery(grid_selector).jqGrid('getGridParam','selrow');

        $(document).on('ajaxloadstart', function (e) {
            $(grid_selector).jqGrid('GridUnload');
            $('.ui-jqdialog').remove();
        });
    });
    $.extend($.jgrid.defaults, {
        ajaxGridOptions: { contentType: "application/json;charset=UTF-8" },
        ajaxRowOptions: { contentType: "application/json;charset=UTF-8" },
        serializeRowData: function(postdata) {
            return JSON.stringify(postdata);
        },
        ajaxSelectOptions: { contentType: "application/json;charset=UTF-8", dataType: "JSON" }

    });
    $.extend($.jgrid.del, {
        ajaxDelOptions: { contentType: "application/json;charset=UTF-8" },
        serializeDelData: function(postdata) {
            return JSON.stringify(postdata);
        }
    })

    var ue;//在线编辑器全局变量
    // 新增
    var addRecord = function () {
        var consoleDlg = $("#consoleDlg");
        var title = $.trim(consoleDlg.find("#title").val());
        if(title == "") {
            alert("标题不能为空！");
            return;
        }
        var summary = $.trim(consoleDlg.find("#summary").val());
        if(summary == "") {
            alert("简介不能为空！");
            return;
        }
        var taxonomyId = "";
        if( $("#taxonomyId_3").val() !="-1"){
            taxonomyId = $("#taxonomyId_3").val();
        } else if ($("#taxonomyId_2").val() !="-1") {
            taxonomyId = $("#taxonomyId_2").val();
        }  else if ($("#taxonomyId_1").val() !="-1") {
            taxonomyId = $("#taxonomyId_1").val();
        }

        if(taxonomyId == ""){
            alert("请选择类目！");
            return;
        }
        var content = ue.getContent();
        if($.trim(content) == ''){
            alert("请编辑内容！");
            return;
        }
        var myData = { "id": "","typeName":"Page","thumbnail":"","taxonomy":[{"id":taxonomyId}],"statusName":"Released"};
        var formData = $('#form1').serializeObject();
        var postData = $.extend({},myData,formData);
        var postJsonStr = JSON.stringify(postData);

        jQuery.ajax( {
            type : 'POST',
            contentType : 'application/json;charset=UTF-8',
            url : '/api/admin/content/detail',
            data : postJsonStr,
            dataType : 'json',
            success : function(response) {
                if (response && response.code == "200") {
                    consoleDlg.dialog( "close" );
                    $(grid_selector).trigger("reloadGrid");
                    alert("新增成功！\n" + "id:"+ response.data.id);
                }else{
                    alert("error:\n" + response.message);
                }
            },
            error : function(data) {
                alert("error")
            }
        });

    }
    //更新
    var updateRecord = function() {
        var consoleDlg = $("#consoleDlg");
        var id = consoleDlg.find("#selectId").val();
        var title = $.trim(consoleDlg.find("#title").val());
        if(title == "") {
            alert("标题不能为空！");
            return;
        }
        var summary = $.trim(consoleDlg.find("#summary").val());
        if(summary == "") {
            alert("简介不能为空！");
            return;
        }
        var taxonomyId = "";
        if( $("#taxonomyId_3").val() !="-1"){
            taxonomyId = $("#taxonomyId_3").val();
        } else if ($("#taxonomyId_2").val() !="-1") {
            taxonomyId = $("#taxonomyId_2").val();
        }  else if ($("#taxonomyId_1").val() !="-1") {
            taxonomyId = $("#taxonomyId_1").val();
        }
        if(taxonomyId == "") {
            taxonomyId = consoleDlg.find("#taxonomyId").val();
        }
        var statusName = consoleDlg.find("#statusName").val();
        var content = ue.getContent();
        if($.trim(content) == ''){
            alert("请编辑内容！");
            return;
        }
        var myData = { "id": id,"typeName":"Page","thumbnail":"","taxonomy":[{"id":taxonomyId}],"statusName":statusName};
         var formData = $('#form1').serializeObject();
        var postData = $.extend({},myData,formData);
        var postJsonStr = JSON.stringify(postData);

        jQuery.ajax( {
            type : 'put',
            contentType : 'application/json;charset=UTF-8',
            url : '/api/admin/content/detail',
            data : postJsonStr,
            dataType : 'json',
            success : function(response) {
                if (response && response.code == "200") {
                    consoleDlg.dialog( "close" );
                    $(grid_selector).trigger("reloadGrid");
                    alert("修改成功！");
                }else{
                    alert("error:\n" + response.message);
                }
            },
            error : function(data) {
                alert("error");
            }
        })
    }
    //查看
    var viewRecord = function() {
        var selectedRowId = $(grid_selector).jqGrid("getGridParam", "selrow");
        if (!selectedRowId) {
            alert("请先选择需要查看的行!");
            return false;
        } else {
            var requestUrl ="/api/admin/content/id/" + selectedRowId;
            $.ajax({
                dataType : "json",
                url : requestUrl,
                cache : false,
                success : function(response){
                    if (response && response.code == "200") {
                        var rowData = response.data;
                        var viewDlg = $("#viewDlg");
                        viewDlg.find("#content").attr("class","content");
                        viewDlg.find("#pgTitle").html(rowData.title);
                        viewDlg.find("#pgAddTime").html(new Date(rowData.addTime).Format("yyyy-MM-dd"));
                        viewDlg.find("#pgViewCount").html(rowData.viewCount + "阅读");
                        viewDlg.find("#pgSummary").html(rowData.summary).attr("class","summary");
                        viewDlg.find("#pgText").html(rowData.text);
                        var width = window.screen.width;
                        if(width >1024) {
                            width = 0.8 * width;
                        } else {
                            width = 0.9 * width;
                        }
                        viewDlg.dialog({width:width,
                            open:function(event,ui) {
                                $(this).parent().focus();//取消第一个元素自动获取焦点
                            }
                        });
                    }else {
                        alert("获取内容信息失败！") ;
                    }
                },
                error:function(){
                    alert("error");
                }
            });
        }
    }
    //删除
    var deleteRecord = function () {
        var consoleDlg = $("#consoleDlg");
        var id = $(grid_selector).jqGrid("getGridParam", "selrow");
        if (!id) {
            alert("请先选择需要删除的行!");
            return false;
        }
            jQuery.ajax( {
            type : 'delete',
            contentType : 'application/json;charset=UTF-8',
            url : '/api/admin/content/id/' + id,
            dataType : 'json',
            success : function(response) {
                if (response && response.code == "200") {
                    consoleDlg.dialog( "close" );
                    $(grid_selector).trigger("reloadGrid");
                    alert("删除成功！");
                }else{
                    alert("error:\n" + response.message);
                }

            },
            error : function(data) {
                alert("error");
            }
        })

    }
    $("#consoleDlg").dialog({
        autoOpen: false,
        modal: true,    // 设置对话框为模态（modal）对话框
        resizable: true,
        width: 900,
        height:620,
        buttons: {  // 为对话框添加按钮
            "新建": addRecord,
            "保存": updateRecord,
            "取消": function() {$("#consoleDlg").dialog("close")},
        },
        open:function() {
            if(!ue){
                ue = UE.getEditor('editor');
            }
        },
        close:function() {
            //重置表单
            $("#form1")[0].reset();
            //重置编辑器
            ue.setContent("");
            resetTaxomonmy();
            //重置图片
            $("#uploadimage").attr("src","").hide();
            $("#delBtn").hide();
        }
    });


    var openDialog4Adding = function() {
        var consoleDlg = $("#consoleDlg");
        var dialogButtonPanel = consoleDlg.siblings(".ui-dialog-buttonpane");
        //consoleDlg.find("input").removeAttr("disabled").val("");
        dialogButtonPanel.find("button:not(:contains('取消'))").hide();
        dialogButtonPanel.find("button:contains('新建')").show();
        loadTaxonomy();//加载类目信息
        consoleDlg.dialog("option", "title", "新建页面").dialog("open");

    };
    var openDialog4Updating = function() {
        var consoleDlg = $("#consoleDlg");
        var dialogButtonPanel = consoleDlg.siblings(".ui-dialog-buttonpane");

        consoleDlg.find("input").removeAttr("disabled");
        dialogButtonPanel.find("button:not(:contains('取消'))").hide();
        dialogButtonPanel.find("button:contains('保存')").show();
        consoleDlg.dialog("option", "title", "修改页面");
        loadSelectedRowData();
    }

    var loadSelectedRowData = function() {
        var selectedRowId = $(grid_selector).jqGrid("getGridParam", "selrow");
        if (!selectedRowId) {
            alert("请先选择需要编辑的行!");
            return false;
        } else {
            var requestUrl ="/api/admin/content/id/" + selectedRowId;
            $.ajax({
                dataType : "json",
                url : requestUrl,
                cache : false,
                success : function(response){
                    if (response && response.code == "200") {
                        var rowData = response.data;
                        var consoleDlg = $("#consoleDlg");
                        consoleDlg.find("#selectId").val(rowData.id);
                        var taxonomyArr = rowData.taxonomy;
                        setTaxonomy(taxonomyArr);
                        var taxonomy = taxonomyArr[taxonomyArr.length-1];
                        var taxonomyId = taxonomy.id;
                        consoleDlg.find("#taxonomyId").val(taxonomyId);
                        consoleDlg.find("#statusName").val(rowData.statusName);
                        consoleDlg.find("#title").val(rowData.title);
                        consoleDlg.find("#summary").val(rowData.summary);

                        if(!ue){
                            ue = UE.getEditor('editor');
                            ue.addListener("ready", function () {
                                ue.setContent(rowData.text);
                            });
                        } else {
                            ue.setContent(rowData.text);
                        }

                        consoleDlg.dialog("open");
                    }else {
                        alert("获取内容信息失败！") ;
                    }
                },
                error:function(){
                    alert("error");
                }
            });

        }
    }

//辅助类
    var addSelOption = function(jq) //方法addSelOption : 为匹配对象添加一项"请选择"， jq ： jQuery对象
    {
        //创建option对象，并设置文本为"请选择"，value值为-1
        var opt = $("<option/>").text("请选择").attr("value", "-1");
        //将option对象添加到select中
        jq.append(opt);
    }
    //加载类目信息
    var loadTaxonomy = function() {
        var requestUrl = "/api/category/lists?parentId=0&size=20&page=1";
    $.ajax({
        //type : "get", //默认为get
        dataType : "json",
        url :  requestUrl,
        success : function(response){
            if (response && response.code == "200") {
                var selectOptions = response.data.items;
                for(var i=0;i<selectOptions.length;i++){
                    $("#taxonomyId_1").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                }
            }else {
                alert("获取类目信息失败！") ;
            }
            $("#taxonomyId_1").change(function(){
                var taxonomyId = $(this).val();
                if(taxonomyId != "-1"){
                    var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                    $.ajax({
                        dataType : "json",
                        url : requestUrl,
                        success : function(response){
                            if (response && response.code == "200") {
                                $("#taxonomyId_2").empty();
                                addSelOption($("#taxonomyId_2"));
                                var selectOptions = response.data.items;
                                for(var i=0;i<selectOptions.length;i++){
                                    $("#taxonomyId_2").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                }
                            }else {
                                alert("获取类目信息失败！") ;
                            }

                        },
                        error:function(){
                            alert("error");
                        }
                    });
                }
                else{
                    $("#taxonomyId_2").empty();
                    addSelOption($("#taxonomyId_2"));
                    $("#taxonomyId_3").empty();
                    addSelOption($("#taxonomyId_3"));
                }
            });
            $("#taxonomyId_2").change(function(){
                var taxonomyId = $(this).val();
                if(taxonomyId != "-1"){
                    var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                    $.ajax({
                        dataType : "json",
                        url : requestUrl,
                        success : function(response){
                            if (response && response.code == "200") {
                                $("#taxonomyId_3").empty();
                                addSelOption($("#taxonomyId_3"));
                                var selectOptions = response.data.items;
                                for(var i=0;i<selectOptions.length;i++){
                                    $("#taxonomyId_3").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                }
                            }else {
                                alert("获取类目信息失败！") ;
                            }
                        },
                        error:function(){
                            alert("error");
                        }
                    });
                }
                else{
                    $("#taxonomyId_3").empty();
                    addSelOption($("#taxonomyId_3"));
                }
            });
        },
        error:function(){
            alert("error");
        }
    });
}
    //加载并回填类目信息
    var setTaxonomy = function(taxonomyArr) {
        if(taxonomyArr.length==1){
            $.ajax({
                //type : "get", //默认为get
                dataType : "json",
                url :  "/api/category/lists?parentId=0&size=20&page=1",
                success : function(response){
                    if (response && response.code == "200") {
                        var selectOptions = response.data.items;
                        for(var i=0;i<selectOptions.length;i++){
                            $("#taxonomyId_1").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                        }
                        $("#taxonomyId_1").val(taxonomyArr[0].id);
                    }else {
                        alert("获取类目信息失败！") ;
                    }
                    $("#taxonomyId_1").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_2").empty();
                                        addSelOption($("#taxonomyId_2"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_2").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }

                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_2").empty();
                            addSelOption($("#taxonomyId_2"));
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                    $("#taxonomyId_2").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_3").empty();
                                        addSelOption($("#taxonomyId_3"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_3").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }
                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                },
                error:function(){
                    alert("error");
                }
            });
        }
        else if(taxonomyArr.length==2){//2级菜单
            $.ajax({
                //type : "get", //默认为get
                dataType : "json",
                url :  "/api/category/lists?parentId=0&size=20&page=1",
                success : function(response){
                    if (response && response.code == "200") {
                        var selectOptions = response.data.items;
                        for(var i=0;i<selectOptions.length;i++){
                            $("#taxonomyId_1").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                        }
                        $("#taxonomyId_1").val(taxonomyArr[0].id);
                    }else {
                        alert("获取类目信息失败！") ;
                    }
                    $.ajax({
                        dataType : "json",
                        url :  "/api/category/lists?parentId="+taxonomyArr[0].id+"&size=20&page=1",
                        success : function(response) {
                            if (response && response.code == "200") {
                                var selectOptions = response.data.items;
                                for (var i = 0; i < selectOptions.length; i++) {
                                    $("#taxonomyId_2").append("<option value='" + selectOptions[i].id + "'>" + selectOptions[i].title + "</option>");
                                }
                                $("#taxonomyId_2").val(taxonomyArr[1].id);
                            }
                        },
                        error:function(){
                            alert("error");
                        }

                    });
                    $("#taxonomyId_1").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_2").empty();
                                        addSelOption($("#taxonomyId_2"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_2").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }

                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_2").empty();
                            addSelOption($("#taxonomyId_2"));
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                    $("#taxonomyId_2").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_3").empty();
                                        addSelOption($("#taxonomyId_3"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_3").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }
                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                },
                error:function(){
                    alert("error");
                }
            });
        }
        else  if(taxonomyArr.length==3){//3级菜单
            $.ajax({
                //type : "get", //默认为get
                dataType : "json",
                url :  "/api/category/lists?parentId=0&size=20&page=1",
                success : function(response){
                    if (response && response.code == "200") {
                        var selectOptions = response.data.items;
                        for(var i=0;i<selectOptions.length;i++){
                            $("#taxonomyId_1").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                        }
                        $("#taxonomyId_1").val(taxonomyArr[0].id);
                    }else {
                        alert("获取类目信息失败！") ;
                    }
                    $.ajax({
                        dataType : "json",
                        url :  "/api/category/lists?parentId="+taxonomyArr[0].id+"&size=20&page=1",
                        success : function(response) {
                            if (response && response.code == "200") {
                                var selectOptions = response.data.items;
                                for (var i = 0; i < selectOptions.length; i++) {
                                    $("#taxonomyId_2").append("<option value='" + selectOptions[i].id + "'>" + selectOptions[i].title + "</option>");
                                }
                                $("#taxonomyId_2").val(taxonomyArr[1].id);
                            }else {
                                alert("获取类目信息失败！") ;
                            }
                            $.ajax({
                                dataType : "json",
                                url :  "/api/category/lists?parentId="+taxonomyArr[1].id+"&size=20&page=1",
                                success : function(response) {
                                    if (response && response.code == "200") {
                                        var selectOptions = response.data.items;
                                        for (var i = 0; i < selectOptions.length; i++) {
                                            $("#taxonomyId_3").append("<option value='" + selectOptions[i].id + "'>" + selectOptions[i].title + "</option>");
                                        }
                                        $("#taxonomyId_3").val(taxonomyArr[2].id);
                                    } else {
                                        alert("获取类目信息失败！");
                                    }
                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        },
                        error:function(){
                            alert("error");
                        }

                    });
                    $("#taxonomyId_1").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_2").empty();
                                        addSelOption($("#taxonomyId_2"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_2").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                        $("#taxonomyId_3").empty();
                                        addSelOption($("#taxonomyId_3"));
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }

                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_2").empty();
                            addSelOption($("#taxonomyId_2"));
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                    $("#taxonomyId_2").change(function(){
                        var taxonomyId = $(this).val();
                        if(taxonomyId != "-1"){
                            var requestUrl = '/api/category/lists?parentId='+ taxonomyId + '&size=20&page=1';
                            $.ajax({
                                dataType : "json",
                                url : requestUrl,
                                success : function(response){
                                    if (response && response.code == "200") {
                                        $("#taxonomyId_3").empty();
                                        addSelOption($("#taxonomyId_3"));
                                        var selectOptions = response.data.items;
                                        for(var i=0;i<selectOptions.length;i++){
                                            $("#taxonomyId_3").append("<option value='"+selectOptions[i].id+"'>"+selectOptions[i].title+"</option>");
                                        }
                                    }else {
                                        alert("获取类目信息失败！") ;
                                    }
                                },
                                error:function(){
                                    alert("error");
                                }
                            });
                        }
                        else{
                            $("#taxonomyId_3").empty();
                            addSelOption($("#taxonomyId_3"));
                        }
                    });
                },
                error:function(){
                    alert("error");
                }
            });
        }


    }
    var resetTaxomonmy = function() {
        $("#taxonomyId_1").empty();
        addSelOption($("#taxonomyId_1"));
        $("#taxonomyId_2").empty();
        addSelOption($("#taxonomyId_2"));
        $("#taxonomyId_3").empty();
        addSelOption($("#taxonomyId_3"));
    }
</script>


</body>
</html>